/*
 * Location.h
 *
 *  Created on: 2011. 3. 15.
 *      Author: JeeHoon
 */
#ifndef LOCATOIN_H
#define LOCATOIN_H

#include <FUix.h>
#include <FLocations.h>
#include "Common.h"
#include "api/Plugin.h"

class PluginManager;

class Location :
	public Plugin,
	public Osp::Uix::ISensorEventListener,
	public Osp::Locations::ILocationListener
{
public:
	Location();
	~Location();

	/* Plugin */
	virtual result OnConstruct(PluginManager * pPluginManager, Osp::Base::String pluginName);
	virtual result execute(Osp::Base::String action, Osp::Base::String args, Osp::Base::String callbackId);

	/* Osp::Uix::ISensorEventListener */
	virtual void OnDataReceived (Osp::Uix::SensorType sensorType, Osp::Uix::SensorData &sensorData, result r);

	/* Osp::Locations::ILocationListener */
	virtual void  OnLocationUpdated (Osp::Locations::Location &location);
	virtual void  OnProviderStateChanged (Osp::Locations::LocProviderState newState);

private:
	Osp::Uix::SensorManager *			__pSensorManager;
	Osp::Locations::LocationProvider * 	__pLocationProvider;

	bool 							__hasCompassListener;
	long int 						__compassInterval;
	long int 						__compassMinInterval;
	long int 						__compassMaxInterval;

	result startHeading(long int interval);
	result stopHeading();

	result startLocation(long int interval,bool enableHighAccuracy, long int timeout, long int maximumAge);
	result stopLocation();
};

#endif //LOCATOIN_H
